<?php
namespace app\controller;
use think\facade\Db;

class Login
{
    public function index()
    {
        
        return view("login");
    }

    /**
     * 管理员登录
     */
    public function login()
    {
        if (request()->isPost()) {
            $username = input('username');
            $password = input('password');
            //此时登录验证应该发送到总控服务端
            $admin = Db::name('user')->where('username', $username)->find();
            if (!$admin || $admin['password'] != $password){
                return 0;
            }
            session("admin", $admin['username']);
            return 1;
        }
    }
}
